<?php
//
// 支持Smarty模板引擎
//

import('#/include/smarty/Smarty.class.php');

class SmartyView
{
	static function initialize()
	{
		$sett	=	app_cfg('smarty.view');
		
		$smarty	=	new Smarty();
		$smarty->compile_dir	=	isset($sett['compile_dir']) ? $sett['compile_dir'] : View::$cacheDir;
		$smarty->cache_dir		=	isset($sett['cache_dir']) ? $sett['cache_dir'] : View::$cacheDir;
		$smarty->template_dir	=	isset($sett['template_dir']) ? $sett['template_dir'] : my_path('%/');
		$smarty->compile_check	=	isset($sett['compile_check']) ? $sett['compile_check'] : Core::cfg('view_cmp_chk');
		$smarty->debugging		=	isset($sett['debugging']) ? $sett['debugging'] : Core::cfg('debug');
		$smarty->php_handling		=	isset($sett['php_handling']) ? $sett['php_handling'] : SMARTY_PHP_REMOVE;
		$smarty->left_delimiter		=	isset($sett['left_delimiter']) ? $sett['left_delimiter'] : '<{';
		$smarty->right_delimiter	=	isset($sett['right_delimiter']) ? $sett['right_delimiter'] : '}>';

		$smarty->register_function('url', 'url');

		$GLOBALS['smarty']	=	$smarty;
	}
	
	static function display($_the_file)
	{
		error_reporting(E_ALL ^ E_NOTICE);
		Core::trackingErrors(false);
		$GLOBALS['smarty']->assign(View::$vars);
		$GLOBALS['smarty']->display($_the_file);
		Core::trackingErrors(true);
		error_reporting(E_ALL);
	}
	
	static function clearCache($theme=null)
	{
	}

}

?>
